/*
Spotter Exercise Manager
Copyright 2011 Evan Nelson.

This file is part of Spotter Exercise Manager.

Spotter Exercise Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Spotter Exercise Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Spotter Exercise Manager.  If not, see <http://www.gnu.org/licenses/>.

The author can be contacted by emailing ean5533@gmail.com
*/

#ifndef SECTIONWEIGHTLIFTING_H
#define SECTIONWEIGHTLIFTING_H

#include <QWidget>
#include <QStackedWidget>
#include <QSqlDatabase>
#include <QDate>
#include <QListWidgetItem>

#include <qwt_plot.h>

namespace Ui {
    class SectionWeightlifting;
}

class SectionWeightlifting : public QWidget
{
    Q_OBJECT

public:
    explicit SectionWeightlifting(QWidget *parent = 0);
    ~SectionWeightlifting();

    void loadEditExWindow();

    QStackedWidget *tabsMain;   //referenced by mainwindow form

protected:
    bool eventFilter(QObject *obj, QEvent *event);

private:
    Ui::SectionWeightlifting *ui;

    //init
    void prepareLogs();
    void prepareTemplates();
    void prepareGraphs();

    //Logs
    void refreshLogs();
    void viewLog(int curLog);
    void editLog(int curLog);
    void deleteLog(int curLog);
    void newLog();
    void viewOrEditCurrentLog();

    //Templates
    void refreshTemplates();
    void editTemplate(int curTemplate);
    void deleteTemplate(int curTemplate);
    void newTemplate();
    void editCurrentTemplate();

    //Graph WtOverTime
    void updateGraphPreview_WtOverTime();
    void updateGraphPreview_WtOverTime(QStringList exercises);

private:
    static const QString baseTitle;  //base title of the main window
    int userID;
    QSqlDatabase db;


//Menu items
private slots:

    //Logs
    void on_btnDeleteLog_clicked();
    void on_btnNewLog_clicked();
    void on_tableLog_doubleClicked();
    void on_btnViewLog_clicked();
    void on_btnEditLog_clicked();
    void on_actionViewLog_triggered();
    void on_actionEditLog_triggered();
    void on_actionDeleteLog_triggered();

    //Templates
    void on_btnDeleteTemplate_clicked();
    void on_btnNewTemplate_clicked();
    void on_tableTemplate_doubleClicked();
    void on_btnEditTemplate_clicked();
    void on_actionEditTemplate_triggered();
    void on_actionDeleteTemplate_triggered();

    //Graph WtOverTime
    void on_btnOpenWtOverTime_clicked();
    void on_listWtOverTime_itemDoubleClicked(QListWidgetItem* item);
    void on_btnWtOverTime_AddEx_clicked();
    void on_chkWtOverTime_To_stateChanged(int );
    void on_chkWtOverTime_From_stateChanged(int );
    void on_cmbWtOverTime_WtType_currentIndexChanged(int index);
    void on_cmbWtOverTime_Ex_currentIndexChanged(int index);

    //Data
    void on_btnEditExercises_clicked();
    void on_toolButton_clicked();
};

#endif // SECTIONWEIGHTLIFTING_H
